#include <iostream>
using namespace std;
int main()
{
    int n=0;
    cin >>n;
    string ud;
    cin >>ud;
    
    int begin=1;
    int end=min(4,n);
    int song=1;
    for(auto& e:ud)
    {
        if(e=='U')
        {
            song=(song-1+n-1)%n+1;
        }
        else if(e=='D')
        {
            song=song%n+1;
        }
        if(song>end)
        {
            end=song;
            begin=end-3;
        }
        else if(song<begin)
        {
            begin=song;
            end=begin+3;
        }
        
    }
    for (int i=begin;i<=end;i++)
    {
        cout << i << " ";
    }
    cout <<endl;
    
    
    cout << song;
    return 0;
}